<script>
    var pnum = {$pnum};
    var goods_id = {$goods_id};
    {if condition="(!isset($search)) OR (!$search)"}
    var search = 0;
    var goUrl = "/{$Request.module}/getgoods/lst/goods_id/"+goods_id+".html?page="+pnum;
    {else/}
        var search = {$search};
        var goUrl = "/{$Request.module}/getgoods/search.html?page="+pnum;
        {/if}

</script>


<table id="sort" class="table table-hover table-bordered">
    <thead>
    <tr>

        <th style="width:35%">商品名称</th>
        <th style="width:45px;">缩略图</th>
        <th style="width:20%">所属分类</th>
        <th style="width:15%">金额</th>
        <th style="width:15%">操作</th>
    </tr>
    </thead>
    <tbody id="goods_table">
    {if condition="$list->isEmpty() == false"}
    {foreach name="list" item="v"}
    <tr id="goods_{$v.id}">

        <td>{$v.goods_name}</td>
        <td><img src="{$v.thumb_url}" class="pop_goods_thumb" onerror="this.src='__PUBLIC__/admin/img/nopic.jpg'"/></td>
        <td>{$v.cate_name}</td>
        <td>{$v.shop_price}</td>
        <td>
            <button type="button" class="btn btn-primary  btn-xs select_goods" onclick="select_goods({$v.id});" data-id="{$v.id}">选择此商品</button>
            <button type="button" class="btn btn-danger btn-xs" onclick="yichu(this);"><i class="fa fa-close"></i>&nbsp;移除</button>
        </td>
    </tr>
    {/foreach}
    {else/}
    <tr><td colspan="7" style="text-align:center; font-size:14px;">没有找到相关数据</td></tr>
    {/if}
    </tbody>
</table>
<div class="row"><div class="pagination" style="float:right; margin-right:20px;">{$page}</div></div>
<script>

    function select_goods(goodsId){
        if(goodsId == ''){
            layer.msg('商品ID参数错误', {icon: 2,time: 1000});
            return false;
        }

        $('#goods_'+goodsId+' .select_goods').hide();
        var html = $('#goods_'+goodsId).prop('outerHTML');
        javascript:window.parent.call_backgoods(goodsId,html);
    }

    function yichu(obj){
        $(obj).parent().parent().remove();
    }
</script>                        